package edu.gym4all.util;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;

import com.example.gym4all.R;

import edu.gym4all.service.ExerciseEnum;

public class AdapterListHyperExercises extends BaseAdapter {

	private LayoutInflater mInflater;
	private List<ItemListHyperExercise> itens;

	public AdapterListHyperExercises(Context context,
			List<ItemListHyperExercise> itens) {
		this.mInflater = LayoutInflater.from(context);
		this.itens = itens;
	}

	@Override
	public int getCount() {
		return this.itens.size();
	}

	@Override
	public Object getItem(int position) {
		return this.itens.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ItemSuporte itemHolder;

		if (convertView == null) {
			convertView = this.mInflater.inflate(
					R.layout.item_list_hyper_exercise, null);

			itemHolder = new ItemSuporte();

			TextView text = ((TextView) convertView
					.findViewById(R.id.itemListHyperExercise));
			// HypertrophyExercise exerciciz
			itemHolder.checkDelete = ((RadioButton) convertView
					.findViewById(R.id.radio_checked));

			itemHolder.series = ((EditText) convertView
					.findViewById(R.id.series));
			itemHolder.reps = ((EditText) convertView.findViewById(R.id.reps));

			convertView.setTag(itemHolder);
		} else {
			itemHolder = (ItemSuporte) convertView.getTag();
		}

		ItemListHyperExercise item = this.itens.get(position);
		// itemHolder.exercise = item.getExercise();
		itemHolder.checkDelete.setChecked(item.getCheckDelete().isActivated());

		return convertView;
	}

	private class ItemSuporte {

		RadioButton checkDelete;
		ExerciseEnum exercise;
		EditText series;
		EditText reps;
	}
}
